const http = require("http")

/**
 * 创建服务器
 */
const server = http.createServer((req, res) => {
  res.statusCode = 200
  res.setHeader("Content-type", "text/plain;charset=utf-8")
  res.end("你好，node.js")
})

/**
 * 发布web服务
 */
const port = 3000;
const host = "localhost"
server.listen(port, host, ()=>{
  console.log(`服务器运行在htp://${host}:${port}`)
})